ALMaSS  1.0
The Animal, Landscape and Man Simulation System
RodenticidePredators_Population_Manager Class Reference

#include <RodenticidePredators.h>

Inheritance diagram for RodenticidePredators_Population_Manager:
Population_Manager

Public Member Functions

virtual ~RodenticidePredators_Population_Manager ()
 
 RodenticidePredators_Population_Manager (Landscape *L)
 
void Tick ()
 Updates the rodenticide exposure for all predator territories. More...
 
void PreCachePoly (int a_poly)
 
vector< RP_Territory > * SupplyTerritories ()
 
int HowManyTerritoriesHere (int a_x, int a_y)
 
- Public Member Functions inherited from Population_Manager
 Population_Manager (Landscape *L)
 
virtual ~Population_Manager (void)
 
void SetNoProbes (int a_pn)
 
unsigned GetLiveArraySize (int a_listindex)
 Gets the number of 'live' objects for a list index in the TheArray. More...
 
void IncLiveArraySize (int a_listindex)
 Increments the number of 'live' objects for a list index in the TheArray. More...
 
virtual void Catastrophe (int)
 
unsigned int FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal)
 
char * SpeciesSpecificReporting (int a_species, int a_time)
 
char * ProbeReport (int a_time)
 
char * ProbeReportTimed (int a_time)
 
void ImpactProbeReport (int a_Time)
 
bool BeginningOfMonth ()
 
void LOG (const char *fname)
 
int SupplyStepSize ()
 
int SupplySimW ()
 
int SupplySimH ()
 
virtual void Run (int NoTSteps)
 
virtual float Probe (int ListIndex, probe_data *p_TheProbe)
 
virtual void ImpactedProbe ()
 
int SupplyListNameLength ()
 
TAnimalSupplyAnimalPtr (int a_index, int a_animal)
 Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK. More...
 
unsigned SupplyListIndexSize ()
 
unsigned SupplyListSize (unsigned listindex)
 
bool CheckXY (int l, int i)
 Debug method to test for out of bounds coordinates. More...
 
const char * SupplyListName (int i)
 
bool IsLast (unsigned listindex)
 
int SupplyState (unsigned listindex, unsigned j)
 
virtual void SupplyLocXY (unsigned listindex, unsigned j, int &x, int &y)
 
const char * SupplyStateNames (int i)
 
unsigned SupplyStateNamesLength ()
 
virtual void DisplayLocations ()
 
int ProbeFileInput (char *p_Filename, int p_ProbeNo)
 
TAnimalFindClosest (int x, int y, unsigned Type)
 
bool OpenTheRipleysOutputProbe (string a_NWordFilename)
 
void OpenTheAOROutputProbe (string a_AORFilename)
 
bool OpenTheMonthlyRipleysOutputProbe ()
 
bool OpenTheReallyBigProbe ()
 
virtual void TheAOROutputProbe ()
 
virtual void TheRipleysOutputProbe (FILE *a_prb)
 
virtual void TheReallyBigOutputProbe ()
 
void CloseTheMonthlyRipleysOutputProbe ()
 
virtual void CloseTheRipleysOutputProbe ()
 
virtual void CloseTheReallyBigOutputProbe ()
 
TTypesOfPopulation GetPopulationType ()
 
int GetSeasonNumber ()
 Get the season number. More...
 
void LamdaDeath (int x, int y)
 
void LamdaBirth (int x, int y)
 
void LamdaBirth (int x, int y, int z)
 
void LamdaClear ()
 
void LamdaDumpOutput ()
 
virtual int SupplyPegPosx (int)
 
virtual int SupplyPegPosy (int)
 
virtual int SupplyCovPosx (int)
 
virtual int SupplyCovPosy (int)
 
virtual bool OpenTheFledgelingProbe ()
 
virtual bool OpenTheBreedingPairsProbe ()
 
virtual bool OpenTheBreedingSuccessProbe ()
 
virtual void BreedingPairsOutput (int)
 
virtual int TheBreedingFemalesProbe (int)
 
virtual int TheFledgelingProbe ()
 
virtual void BreedingSuccessProbeOutput (double, int, int, int, int, int, int, int)
 
virtual int TheBreedingSuccessProbe (int &, int &, int &, int &, int &, int &)
 
virtual void FledgelingProbeOutput (int, int)
 
virtual void TheGeneticProbe (unsigned, int, unsigned &)
 
virtual void GeneticsResultsOutput (FILE *, unsigned)
 

Protected Member Functions

double EvaluatePoly (int a_poly)
 Get the habitat quality based on polygon type. More...
 
void ReadHabitatValues (int a_type)
 Read in specific predator type habitat scores. More...
 
void CreatHabitatQualGrid (void)
 Evaluate the landscape and create the habitat quality grid. More...
 
void CreateTerritories ()
 Populates the landscape with predatory territories. More...
 
void PredatorTerritoryOutput (bool a_initial)
 Output functions for predator territories. More...
 
void PredatorTerritoryInput ()
 Output functions for predator territories. More...
 
bool IsGridPositionValid (int &x, int &y, int range)
 Tests whether a square has any occupied cells. More...
 
double EvaluateHabitat (int a_x, int a_y, int a_range)
 Gets the total habitat score for a square UL x,y diameter of range. More...
 
void NewTerritory (int a_x, int a_y, int a_range, double a_qual)
 Create a new territory and claim the grid. More...
 
- Protected Member Functions inherited from Population_Manager
virtual bool StepFinished ()
 Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour. More...
 
virtual void DoFirst ()
 
virtual void DoBefore ()
 
virtual void DoAfter ()
 
virtual void DoAlmostLast ()
 
virtual void DoLast ()
 
void EmptyTheArray ()
 Removes all objects from the TheArray by deleting them and clearing TheArray. More...
 
void SortX (unsigned Type)
 
void SortXIndex (unsigned Type)
 
void SortY (unsigned Type)
 
void SortState (unsigned Type)
 
void SortStateR (unsigned Type)
 
unsigned PartitionLiveDead (unsigned Type)
 
void Shuffle_or_Sort (unsigned Type)
 
void Shuffle (unsigned Type)
 
virtual void Catastrophe ()
 

Protected Attributes

int m_sim_w
 
int m_sim_h
 
int m_sim_w_div_10
 
int m_sim_h_div_10
 
int m_hash_size
 
double * m_qual_cache
 
double * m_qual_grid
 
bool * m_occupancy_grid
 
double m_habquals [tole_Foobar]
 
int m_predator_minHR
 
int m_predator_maxHR
 
double m_predator_targetQual
 
vector< RP_Territorym_Territories
 
int m_NoTerritories
 
double m_summeddays
 Keeps track of the number of days we have rodenticide exposure summation for. More...
 
- Protected Attributes inherited from Population_Manager
vector< unsigned > m_LiveArraySize
 
int m_NoProbes
 
AOR_Probem_AOR_Probe
 
FILE * m_GeneticsFile
 
FILE * m_AlleleFreqsFile
 
FILE * m_EasyPopRes
 
const char * StateNames [100]
 
int m_catastrophestartyear
 
int m_StepSize
 
vector< TListOfAnimalsTheArray
 
unsigned StateNamesLength
 
const char * m_ListNames [32]
 
unsigned m_ListNameLength
 
FILE * TestFile
 
FILE * TestFile2
 
unsigned BeforeStepActions [12]
 
int m_SeasonNumber
 Holds the season number. Used when running goose and hunter sims. More...
 
TTypesOfPopulation m_population_type
 
ofstream * AOROutputPrb
 
FILE * RipleysOutputPrb
 
FILE * RipleysOutputPrb1
 
FILE * RipleysOutputPrb2
 
FILE * RipleysOutputPrb3
 
FILE * RipleysOutputPrb4
 
FILE * RipleysOutputPrb5
 
FILE * RipleysOutputPrb6
 
FILE * RipleysOutputPrb7
 
FILE * RipleysOutputPrb8
 
FILE * RipleysOutputPrb9
 
FILE * RipleysOutputPrb10
 
FILE * RipleysOutputPrb11
 
FILE * RipleysOutputPrb12
 
FILE * ReallyBigOutputPrb
 
long int lamdagrid [2][257][257]
 

Additional Inherited Members

- Public Attributes inherited from Population_Manager
int IndexArrayX [5][10000]
 
probe_dataTheProbe [100]
 
int SimH
 
int SimW
 
unsigned SimHH
 
unsigned SimWH
 
char m_SimulationName [255]
 
bool ProbesSet
 
Landscapem_TheLandscape
 

Constructor & Destructor Documentation

◆ ~RodenticidePredators_Population_Manager()

RodenticidePredators_Population_Manager::~RodenticidePredators_Population_Manager ( )
virtual

When the manager is destroyed call the output functions for predator territories

61 {
66  delete m_qual_cache;
67  delete m_qual_grid;
68  delete m_occupancy_grid;
69 }
double * m_qual_cache
Definition: RodenticidePredators.h:73
double * m_qual_grid
Definition: RodenticidePredators.h:74
void PredatorTerritoryOutput(bool a_initial)
Output functions for predator territories.
Definition: RodenticidePredators.cpp:333
bool * m_occupancy_grid
Definition: RodenticidePredators.h:75

References m_occupancy_grid, m_qual_cache, m_qual_grid, and PredatorTerritoryOutput().

◆ RodenticidePredators_Population_Manager()

RodenticidePredators_Population_Manager::RodenticidePredators_Population_Manager ( Landscape L)

On construction the first thing to do is to read the quality scores in from the correct predator input file. This depends on a config variable being correctly set: cfg_RodenticidePredatoryType

Create the habitat quality grid ready for predatory habitat assessment

Now populate the landscape with predatory territories

71  : Population_Manager(a_L)
72 {
73  m_predator_minHR = cfg_RodenticidePredatoryMinTerr.value() / 10; // Need divind by 10 for the grid (it is in 10 x 10m grids)
76  m_summeddays = 0.0;
90  else
91  {
94  }
95 
96 }
CfgBool cfg_rodenticide_read_predators("RODENTICIDE_READ_PREDATORS", CFG_CUSTOM, false)
Used to flag whether we calculate or read in territory values.
CfgInt cfg_RodenticidePredatoryMaxTerr("RODPREDATOR_MAXTERR", CFG_CUSTOM, 500)
Maximum territory width.
CfgInt cfg_RodenticidePredatoryMinTerr("RODPREDATOR_MINTERR", CFG_CUSTOM, 100)
Minimum territory width.
CfgInt cfg_RodenticidePredatoryType("RODPREDATOR_TYPE", CFG_CUSTOM,-1)
Used to set the predator information to read in.
CfgInt cfg_RodenticidePredatoryTargetQual("RODPREDATOR_TARGETQUAL", CFG_CUSTOM, 100)
Territory minimum quality.
bool value(void)
Definition: configurator.h:135
int value(void)
Definition: configurator.h:98
Population_Manager(Landscape *L)
Definition: PopulationManager.cpp:221
void PredatorTerritoryInput()
Output functions for predator territories.
Definition: RodenticidePredators.cpp:358
void CreatHabitatQualGrid(void)
Evaluate the landscape and create the habitat quality grid.
Definition: RodenticidePredators.cpp:99
double m_summeddays
Keeps track of the number of days we have rodenticide exposure summation for.
Definition: RodenticidePredators.h:85
double m_predator_targetQual
Definition: RodenticidePredators.h:79
void ReadHabitatValues(int a_type)
Read in specific predator type habitat scores.
Definition: RodenticidePredators.cpp:151
int m_predator_minHR
Definition: RodenticidePredators.h:77
int m_predator_maxHR
Definition: RodenticidePredators.h:78
void CreateTerritories()
Populates the landscape with predatory territories.
Definition: RodenticidePredators.cpp:194

References cfg_rodenticide_read_predators, cfg_RodenticidePredatoryMaxTerr, cfg_RodenticidePredatoryMinTerr, cfg_RodenticidePredatoryTargetQual, cfg_RodenticidePredatoryType, CreateTerritories(), CreatHabitatQualGrid(), m_predator_maxHR, m_predator_minHR, m_predator_targetQual, m_summeddays, PredatorTerritoryInput(), PredatorTerritoryOutput(), ReadHabitatValues(), CfgInt::value(), and CfgBool::value().

Member Function Documentation

◆ CreateTerritories()

void RodenticidePredators_Population_Manager::CreateTerritories ( )
protected

Populates the landscape with predatory territories.

Starts with a minimum territory size territory and then increases the size until either a occupied square is found or max size is reached, or the quality level has been met.

195 {
196  m_NoTerritories = 0;
197  int x0 = m_predator_maxHR / 2; // Our starting point x
198  int x = (int) (x0+g_rand_uni()*(m_sim_w_div_10 - x0));
199  int y = x0; // Our starting point y
200  int x1 = m_sim_w_div_10 - x0; // End point x
201  int y1 = m_sim_h_div_10 - x0; // End point y
202  //bool toggle = false;
203  double qual;
204  int range;
208  int tries = m_sim_w_div_10 * m_sim_h_div_10; // the number of grid points in the grid
209  while ( tries-- > 0)
210  {
211  //if (toggle) if (y>=starty) break;
212  range = m_predator_minHR;
213  bool found = false;
214  while ( ( range <= m_predator_maxHR ) && ( !found ))
215  {
216  if ( !IsGridPositionValid( x, y, range ) )
217  {
218  if ( ++x >= x1 )
219  {
220  x = 0; //random( 3 );
221  if ( ++y >= y1 )
222  {
223  tries = 0; // Gone all the way round so stop
224  range = m_predator_maxHR +1;
225  //toggle = true;
226  }
227  }
228  continue;
229  }
230  // Location was OK, ie. not occupied.
231  // Try the smallest possible territory located right at our starting
232  // position.
233  qual = EvaluateHabitat( x, y, range );
234  // Is it suitable?
235  if ( qual >= m_predator_targetQual )
236  {
237  // If so create it and claim the area on the grid
238  // Is OK so create a territory
239  NewTerritory( x, y, range, 0.0 );
240  found = true;
241  }
242  else range++;
243  }
244  // Take a step and try again
245  if (++x >= x1)
246  {
247  x = x0;
248  if (++y >= y1)
249  {
250  tries = 0; // Gone all the way round so stop
251  range = m_predator_maxHR + 1;
252  //toggle = true;
253  }
254  }
255  }
256 }
int m_sim_h_div_10
Definition: RodenticidePredators.h:71
int m_sim_w_div_10
Definition: RodenticidePredators.h:70
double EvaluateHabitat(int a_x, int a_y, int a_range)
Gets the total habitat score for a square UL x,y diameter of range.
Definition: RodenticidePredators.cpp:288
int m_NoTerritories
Definition: RodenticidePredators.h:81
void NewTerritory(int a_x, int a_y, int a_range, double a_qual)
Create a new territory and claim the grid.
Definition: RodenticidePredators.cpp:308
bool IsGridPositionValid(int &x, int &y, int range)
Tests whether a square has any occupied cells.
Definition: RodenticidePredators.cpp:259
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni

References EvaluateHabitat(), g_rand_uni, IsGridPositionValid(), m_NoTerritories, m_predator_maxHR, m_predator_minHR, m_predator_targetQual, m_sim_h_div_10, m_sim_w_div_10, and NewTerritory().

Referenced by RodenticidePredators_Population_Manager().

◆ CreatHabitatQualGrid()

void RodenticidePredators_Population_Manager::CreatHabitatQualGrid ( void  )
protected

Evaluate the landscape and create the habitat quality grid.

Need to do the basic read and quality assessment for the landscape, before creating and allocating the predatory territories. The first step is to get the map dimensions saved to local attributes.

Following that all the polygons in the landscape are pre-cached for their quality score - this is important for speed because it only needs to be done once per polygon.

Finally go through the whole landscape in 10x10m blocks and fill in the quality grid scoresas a the mean of 100m2 i.e. 10 x 10 m squares

100 {
108  m_sim_w_div_10 = m_sim_w / 10;
109  m_sim_h_div_10 = m_sim_h / 10;
114  m_qual_cache = new double[m_hash_size];
116  /*
117  * Next the memory required for operations is reserved for the quality grid and occupancy grid that we need for the territory finding operations.
118  * The occupancy grid also needs all elements set to false.
119  */
120  int totalgrids = m_sim_w_div_10 * m_sim_h_div_10;
121  m_qual_grid = new double[ totalgrids ];
122  m_occupancy_grid = new bool [ totalgrids ];
123  for (int i=0; i<totalgrids; i++)
124  {
125  m_occupancy_grid[ i ] = false;
126  }
130  for (int x=0; x< m_sim_w_div_10; x++)
131  {
132  for (int y = 0; y < m_sim_h_div_10; y++)
133  {
134  int cx = x*10;
135  int cy = y*10;
136  double qual = 0.0;
137  for (int xx = cx; xx < cx+10; xx++)
138  {
139  for (int yy = cy; yy < cy+10; yy++)
140  {
141  int poly = m_TheLandscape->SupplyPolyRef(xx,yy);
142  qual += m_qual_cache[poly];
143  }
144  }
145  m_qual_grid[x + (y * m_sim_w_div_10)] = qual/=100.0;
146  }
147  }
148 }
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
void RodenticidePredatorsEvaluation(RodenticidePredators_Population_Manager *a_rppm)
Definition: Landscape.cpp:3032
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1488
int SupplyLargestPolyNumUsed()
Definition: landscape.h:355
Landscape * m_TheLandscape
Definition: PopulationManager.h:515
int m_hash_size
Definition: RodenticidePredators.h:72
int m_sim_h
Definition: RodenticidePredators.h:69
int m_sim_w
Definition: RodenticidePredators.h:68

References m_hash_size, m_occupancy_grid, m_qual_cache, m_qual_grid, m_sim_h, m_sim_h_div_10, m_sim_w, m_sim_w_div_10, Population_Manager::m_TheLandscape, Landscape::RodenticidePredatorsEvaluation(), Landscape::SupplyLargestPolyNumUsed(), Landscape::SupplyPolyRef(), Landscape::SupplySimAreaHeight(), and Landscape::SupplySimAreaWidth().

Referenced by RodenticidePredators_Population_Manager().

◆ EvaluateHabitat()

double RodenticidePredators_Population_Manager::EvaluateHabitat ( int  a_x,
int  a_y,
int  a_range 
)
protected

Gets the total habitat score for a square UL x,y diameter of range.

Looks through the area summing all scores.

289 {
291  double l_qual = 0.0;
292  int r2 = a_range / 2;
293  int l_min_x = a_x - r2;
294  int l_min_y = a_y - r2;
295  int l_max_x = a_x + r2;
296  int l_max_y = a_y + r2;
297  for (int x = l_min_x; x < l_max_x; x++)
298  {
299  for ( int y = l_min_y; y < l_max_y; y++ )
300  {
301  l_qual += m_qual_grid[ x + y * m_sim_w_div_10 ];
302  }
303  }
304  return l_qual;
305 }

References m_qual_grid, and m_sim_w_div_10.

Referenced by CreateTerritories().

◆ EvaluatePoly()

double RodenticidePredators_Population_Manager::EvaluatePoly ( int  a_poly)
protected

Get the habitat quality based on polygon type.

Returns the specific score for this polygon based on the polygon type and the score stored in m_habquals

185 {
190  return m_habquals[(int) l_type];
191 }
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
double m_habquals[tole_Foobar]
Definition: RodenticidePredators.h:76
TTypesOfLandscapeElement
Definition: tole_declaration.h:36

References m_habquals, Population_Manager::m_TheLandscape, and Landscape::SupplyElementType().

Referenced by PreCachePoly().

◆ HowManyTerritoriesHere()

int RodenticidePredators_Population_Manager::HowManyTerritoriesHere ( int  a_x,
int  a_y 
)
411 {
412  int sum = 0;
413  int sz = (int)m_Territories.size();
414  for (int t = 0; t< sz; t++)
415  {
416  int r = m_Territories[t].m_range;
417  int x = m_Territories[t].m_x - (r / 2);
418  int y = m_Territories[t].m_y - (r / 2);
419  if ((a_x >= x) && (a_x<x + r) && (a_y >= y) && (a_y <= y + r)) sum++;
420  }
421  return sum;
422 }
vector< RP_Territory > m_Territories
Definition: RodenticidePredators.h:80

References m_Territories.

◆ IsGridPositionValid()

bool RodenticidePredators_Population_Manager::IsGridPositionValid ( int &  x,
int &  y,
int  range 
)
protected

Tests whether a square has any occupied cells.

Returns
false if any occupied grid cell is found If we are too near the edge then do not evaluate,

otherwise test each potential location to see if they are occupied - if so return false

260 {
265  int r2 = a_range / 2;
266  int l_min_x = a_x - r2;
267  int l_min_y = a_y - r2;
268  int l_max_x = a_x + r2;
269  int l_max_y = a_y + r2;
273  for (int i = l_min_x; i < l_max_x; i++)
274  {
275  for (int j = l_min_y; j < l_max_y; j++)
276  {
277  if ( m_occupancy_grid[ i + j * m_sim_w_div_10 ] )
278  {
279  return false;
280  }
281  }
282  }
283  // No occupied squares found so return true
284  return true;
285 }

References m_occupancy_grid, and m_sim_w_div_10.

Referenced by CreateTerritories().

◆ NewTerritory()

void RodenticidePredators_Population_Manager::NewTerritory ( int  a_x,
int  a_y,
int  a_range,
double  a_qual 
)
protected

Create a new territory and claim the grid.

309 {
310  RP_Territory rpt;
311  rpt.m_exposure = a_exposure;
312  rpt.m_range = (int) floor(0.5+(a_range * 10 * cfg_RodenticidePredatoryTerrOverlap.value()));
313  rpt.m_x = a_x * 10;
314  rpt.m_y = a_y * 10;
315  m_Territories.push_back(rpt);
316  // Claim the territory in the grid
317  int r2 = a_range / 2;
318  int l_min_x = a_x - r2;
319  int l_min_y = a_y - r2;
320  int l_max_x = a_x + r2;
321  int l_max_y = a_y + r2;
322 
323  for (int i = l_min_x; i < l_max_x; i++)
324  {
325  for (int j = l_min_y; j < l_max_y; j++)
326  {
327  m_occupancy_grid[ i + j * m_sim_w_div_10 ] = true;
328  }
329  }
330 }
CfgFloat cfg_RodenticidePredatoryTerrOverlap("RODPREDATOR_TERR_OVERLAP", CFG_CUSTOM, 1.0)
Unused.
double value(void)
Definition: configurator.h:118
A data struct to hold RodenticidePredatory territory details.
Definition: RodenticidePredators.h:43
double m_exposure
Definition: RodenticidePredators.h:47
int m_y
Definition: RodenticidePredators.h:45
int m_range
Definition: RodenticidePredators.h:46
int m_x
Definition: RodenticidePredators.h:44

References cfg_RodenticidePredatoryTerrOverlap, RP_Territory::m_exposure, m_occupancy_grid, RP_Territory::m_range, m_sim_w_div_10, m_Territories, RP_Territory::m_x, RP_Territory::m_y, and CfgFloat::value().

Referenced by CreateTerritories().

◆ PreCachePoly()

void RodenticidePredators_Population_Manager::PreCachePoly ( int  a_poly)
inline
61  {
62  m_qual_cache[a_poly] = EvaluatePoly(a_poly);
63  }
double EvaluatePoly(int a_poly)
Get the habitat quality based on polygon type.
Definition: RodenticidePredators.cpp:184

References EvaluatePoly(), and m_qual_cache.

Referenced by Landscape::RodenticidePredatorsEvaluation().

◆ PredatorTerritoryInput()

void RodenticidePredators_Population_Manager::PredatorTerritoryInput ( )
protected

Output functions for predator territories.

Opens a standard output tab-delimited text file and reads all predatory territory information in the format:
Number of entries
Entry 1 x, Entry 1 y, Entry 1 size, Entry 1 exposure
Entry 2 x, Entry 2 y, Entry 2 size, Entry 2 exposure
Entry 3 x etc....

359 {
366  ifstream ifile("PredatorTerritoryOutputInfo.txt",ios::in);
367  int sz;
368  ifile >> sz;
369  double skip;
370  int x,y,range;
371  m_Territories.resize(0);
372  for (int i=0; i< sz; i++)
373  {
374  ifile >> x >> y >> range >> skip;
375  RP_Territory rpt;
376  rpt.m_exposure = 0.0;
377  rpt.m_range = range;
378  rpt.m_x = x;
379  rpt.m_y = y;
380  m_Territories.push_back(rpt);
381  }
382  ifile.close();
383 }

References RP_Territory::m_exposure, RP_Territory::m_range, m_Territories, RP_Territory::m_x, and RP_Territory::m_y.

Referenced by RodenticidePredators_Population_Manager().

◆ PredatorTerritoryOutput()

void RodenticidePredators_Population_Manager::PredatorTerritoryOutput ( bool  a_initial)
protected

Output functions for predator territories.

Opens a standard output tab-delimited text file and dumps all predatory territory information in the format:
Number of entries
Entry 1 x, Entry 1 y, Entry 1 size, Entry 1 exposure
Entry 2 x, Entry 2 y, Entry 2 size, Entry 2 exposure
Entry 3 x etc....

334 {
341  ofstream ofile("PredatorTerritoryOutputInfo.txt",ios::out);
342  int sz = (int) m_Territories.size();
343  ofile << sz << endl;
344  double asum=0.0;
345  for (int i=0; i< sz; i++) asum+=m_Territories[i].m_exposure;
346  if ((asum==0.0) || (m_summeddays<1)) a_initial = true;
347  for (int i=0; i< sz; i++)
348  {
349  ofile << m_Territories[i].m_x << '\t';
350  ofile << m_Territories[i].m_y << '\t';
351  ofile << m_Territories[i].m_range << '\t';
352  if (a_initial) ofile << 0.0 << endl; else ofile << m_Territories[i].m_exposure/m_summeddays << endl;
353  }
354  ofile.close();
355 }

References m_summeddays, and m_Territories.

Referenced by RodenticidePredators_Population_Manager(), and ~RodenticidePredators_Population_Manager().

◆ ReadHabitatValues()

void RodenticidePredators_Population_Manager::ReadHabitatValues ( int  a_type)
protected

Read in specific predator type habitat scores.

This method picks the input file based on the parameter a_type and reads in the scores for each habitat for that predator type. These are stored in m_habquals for later use in habitat evaluation.

152 {
157  fstream ifile;
158  switch (a_type)
159  {
160  case 0:
161  ifile.open("RodenticidePredator0_HabitatScores.txt",ios::in);
162  break;
163  default:
164  ifile.open("RodenticidePredatorNone_HabitatScores.txt",ios::in);
165  }
166  if (!ifile)
167  {
168  m_TheLandscape->Warn("RodenticidePredators_Population_Manager::ReadHabitatValues","Could Not Open Predator Habitat Scores File");
169  exit(0);
170  }
171  int n_values;
172  ifile >> n_values;
173  if (n_values != tole_Foobar)
174  {
175  m_TheLandscape->Warn("RodenticidePredators_Population_Manager::ReadHabitatValues"," - wrong number of habitat scores in RodenticidePredator_HabitatScores.txt");
176  exit(0);
177  }
178  for (int i = 0; i< tole_Foobar; i++) ifile >> m_habquals[i];
179  ifile.close();
180 }
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
@ tole_Foobar
Definition: tole_declaration.h:111

References m_habquals, Population_Manager::m_TheLandscape, tole_Foobar, and Landscape::Warn().

Referenced by RodenticidePredators_Population_Manager().

◆ SupplyTerritories()

vector<RP_Territory>* RodenticidePredators_Population_Manager::SupplyTerritories ( )
inline
64 { return &m_Territories; }

References m_Territories.

◆ Tick()

void RodenticidePredators_Population_Manager::Tick ( void  )

Updates the rodenticide exposure for all predator territories.

Runs through all the territories and sums up the rodenticide exposure and accumulates this in each territory

387 {
391  int sz = (int) m_Territories.size();
392  for (int t=0; t< sz; t++)
393  {
394  int x = m_Territories[t].m_x;
395  int y = m_Territories[t].m_y;
396  int r = m_Territories[t].m_range;
397  int xr = x+r;
398  int yr = y+r;
399  if (xr >= m_sim_w ) xr = m_sim_w-1;
400  if (yr >= m_sim_h ) yr = m_sim_h-1;
401  for (int i=x; i<xr; i++)
402  for (int j=y; j< yr; j++)
403  {
404  m_Territories[t].m_exposure += m_TheLandscape->SupplyRodenticide(i,j);
405  }
406  }
407  m_summeddays++;
408 }
double SupplyRodenticide(int a_x, int a_y)
Gets total rodenticide for a location.
Definition: Landscape.cpp:492

References m_sim_h, m_sim_w, m_summeddays, m_Territories, Population_Manager::m_TheLandscape, and Landscape::SupplyRodenticide().

Member Data Documentation

◆ m_habquals

double RodenticidePredators_Population_Manager::m_habquals[tole_Foobar]
protected

Referenced by EvaluatePoly(), and ReadHabitatValues().

◆ m_hash_size

int RodenticidePredators_Population_Manager::m_hash_size
protected

Referenced by CreatHabitatQualGrid().

◆ m_NoTerritories

int RodenticidePredators_Population_Manager::m_NoTerritories
protected

Referenced by CreateTerritories().

◆ m_occupancy_grid

bool* RodenticidePredators_Population_Manager::m_occupancy_grid
protected

◆ m_predator_maxHR

int RodenticidePredators_Population_Manager::m_predator_maxHR
protected

◆ m_predator_minHR

int RodenticidePredators_Population_Manager::m_predator_minHR
protected

◆ m_predator_targetQual

double RodenticidePredators_Population_Manager::m_predator_targetQual
protected

◆ m_qual_cache

double* RodenticidePredators_Population_Manager::m_qual_cache
protected

◆ m_qual_grid

double* RodenticidePredators_Population_Manager::m_qual_grid
protected

◆ m_sim_h

int RodenticidePredators_Population_Manager::m_sim_h
protected

Referenced by CreatHabitatQualGrid(), and Tick().

◆ m_sim_h_div_10

int RodenticidePredators_Population_Manager::m_sim_h_div_10
protected

◆ m_sim_w

int RodenticidePredators_Population_Manager::m_sim_w
protected

Referenced by CreatHabitatQualGrid(), and Tick().

◆ m_sim_w_div_10

int RodenticidePredators_Population_Manager::m_sim_w_div_10
protected

◆ m_summeddays

double RodenticidePredators_Population_Manager::m_summeddays
protected

Keeps track of the number of days we have rodenticide exposure summation for.

Referenced by PredatorTerritoryOutput(), RodenticidePredators_Population_Manager(), and Tick().

◆ m_Territories

vector<RP_Territory> RodenticidePredators_Population_Manager::m_Territories
protected

The documentation for this class was generated from the following files: